<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>$timeout与$interval实际应用</title>
		<script src="../org/angular.min.js"></script>
		<script type="text/javascript" src="../org/jquery.min.js" ></script>
	</head>
	<body>
		<div ng-app="hd" ng-controller="ctrl">
			{{name}}
			<hr />
			{{id}}
		</div>
		<script>
			var m = angular.module('hd',[]);
			m.controller('ctrl',['$scope','$timeout','$interval',function($scope,$timeout,$interval){
				$scope.name = "renren";
				$scope.id = 1;
//				setTimeout(function(){
//					$scope.name = "人人";
//					$scope.$apply();
//				},2000);
//              var timeOut = $timeout(function(){
//              	$scope.name = "人人";
//              },2000);
                /*setInterval(function(){
                	$scope.name += "renren";
                	$scope.$apply();
                },2000);*/
                var intervalId = $interval(function(){
                	$scope.id ++;
                	if($scope.id > 10){
                		$interval.cancel(intervalId);
                	}
                	
                },1000);
			}])
		</script>
	</body>
</html>
